package com.seari.groovyrunner.config;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

public class AuthInterceptor extends HandlerInterceptorAdapter {
    // 白名单设置
    private List<String> allowUrls;

    @Override
    public boolean preHandle(HttpServletRequest req,
                             HttpServletResponse res, Object handler) throws Exception {
        String requestUrl = req.getRequestURI();

        req.setCharacterEncoding("UTF-8");
        if (requestUrl.startsWith("/groovyDynamic")){
            // todo 权限控制
            System.out.println("动态 url ");
//            return false;
        }

        return true;
    }


    public List<String> getAllowUrls() {
        return allowUrls;
    }

    public void setAllowUrls(List<String> allowUrls) {
        this.allowUrls = allowUrls;
    }
}
